﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web.Script.Serialization;

namespace Client
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        string name;
        string urlimage;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserName"] == null)
            {
                Response.Redirect("MainBlog.aspx");
            }
            name =Session["UserName"].ToString();
            Label2.Text = name;
            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("http://localhost:18796/");

                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));


                HttpResponseMessage response = client.GetAsync("api/values/?name=" + name + "&id=" + 1 + "&id1=" + 2).Result;
                if (response.IsSuccessStatusCode)
                {
                    string a = response.Content.ReadAsStringAsync().Result;

                    string[] temp = a.Split('"');
                    urlimage = temp[1];
                    Image1.Width=100;
                    Image1.Height = 100;
                    Image1.ImageUrl = urlimage;
                }
                else
                {

                }
            }
            catch (Exception ex)
            {
            }
        }
        public string ReturnName()
        {
            return (new JavaScriptSerializer()).Serialize(name);
        }
        public string Image()
        {
            return (new JavaScriptSerializer()).Serialize(urlimage);
        }
    }
}